home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 32 / uswar.zip / NAVY.PAS < prev    next >
Pascal/Delphi Source File  |  1986-02-12  |  12KB  |  400 lines

  1. Program USNAVY;
  2.  
  3. {This module will ask the player to select his navy.  Possible ships to
  4. select from will be displayed.
  5.  
  6. Read theater and ship selection information
  7. Do until last (20) axis ship moved
  8. .   Move next ship to axis navy
  9. End
  10. Display axis ship information
  11. Display allied ship selection information
  12. Initialize navy data
  13. Do until selections complete [END key]
  14. .   Display assets available and ship count
  15. .   Move cursor to selection
  16. .   If ship already selected
  17. .   .   Remove ship from allied navy
  18. .   .   Decrement ship count by 1
  19. .   .   Redisplay ship unhighlighted
  20. .   .   Add cost back to assets
  21. .   Else
  22. .   .   Increment ship count by 1
  23. .   .   If count > maximum allowed
  24. .   .   .   Increment ship count and ignore selection
  25. .   .   Else
  26. .   .   .   Deduct cost from assets
  27. .   .   .   If assets < 0
  28. .   .   .   .   Add cost back to assets
  29. .   .   .   .   Increment ship count by 1
  30. .   .   .   Else
  31. .   .   .   .   Move ship to allied navy
  32. .   .   .   .   Redisplay ship highlighted
  33. .   .   .   End
  34. .   .   End
  35. .   End
  36. End
  37.  
  38. Display battle order of allied navies
  39. Chain FLEETS Module}
  40.  
  41. {$I COMMON.PAS}
  42. {$I BORDER.PAS}
  43. {$I CURSOR.PAS}
  44. {$I PUTPIC.PAS}
  45.  
  46. Type
  47.     Tempship = record
  48.                ID:string[10];
  49.                Attack:integer;
  50.                Defense:integer;
  51.                Model:char;
  52.                Theater:integer;
  53.                Select:char;
  54.                end;
  55.  
  56. Var
  57.     Taken:array[1..20] of integer;
  58.     Available:array[1..48] of tempship;
  59.     ShipsAllow:integer;
  60.     xcnt,acnt,t,u,v:integer;
  61.     d:char;
  62.     Points:integer;
  63.     Temp_Type:string[10];
  64.  
  65. Procedure Ship_Stats(s:integer);
  66. begin
  67. with Available[s] do
  68. begin
  69.   Gotoxy(2,14);
  70.   Temp_type:='          ';
  71.   case model of
  72.     'B': Temp_Type:='Battleship';
  73.     'C': Temp_Type:='Crusier   ';
  74.     'D': Temp_Type:='Destroyer ';
  75.     'S': Temp_Type:='Submarine ';
  76.     'V': Temp_Type:='Convoy    ';
  77.     'A': Temp_Type:='Carrier   ';
  78.     'K': Temp_Type:='Kamikazi  ';
  79.     'M': Temp_Type:='Mtr.Ptl.Bt';
  80.     'P': Temp_Type:='Planes    ';
  81.   end;
  82.   Gotoxy(2,14);
  83.   FastWrite(Concat('Type-',Temp_Type),7,0,1);
  84.   Gotoxy(20,14);
  85.   LowVideo;
  86.   Write('Attack-',Attack);
  87.   Gotoxy(30,14);
  88.   Write('Defense-',Defense);
  89. end;
  90. Gotoxy(41,14);
  91. Fastwrite('Theater limitations-',7,0,1);
  92. if available[s].theater=0 then
  93.   Fastwrite('Unlimited       ',7,0,1)
  94. else
  95.   Write(Theater[available[s].theater].name,'        ');
  96. end;
  97.  
  98. Begin
  99. ClrScr;
  100.  
  101. Theacnt:=0;
  102. Xcnt:=0;
  103. Acnt:=0;
  104. for i:=1 to 20 do                                {Clear old garbage}
  105.   begin
  106.      with axis_navy[i] do
  107.        begin
  108.          Id:='          ';
  109.          Model:=' ';
  110.          Theater:=0;
  111.          Status:=9;
  112.          Attack:=0;
  113.          Defense:=0;
  114.          Damage:=0;
  115.          Fleet:=0;
  116.          Work1:=0;
  117.          Work2:=0;
  118.        end;
  119.     with allied_navy[i] do
  120.        begin
  121.          Id:='          ';
  122.          Model:=' ';
  123.          Theater:=0;
  124.          Status:=9;
  125.          Attack:=0;
  126.          Defense:=0;
  127.          Damage:=0;
  128.          Fleet:=0;
  129.          Work1:=0;
  130.          Work2:=0;
  131.        end;
  132.   end;
  133. Assign(Source,ConCat(Name,'.dat'));              {Open selected data file}
  134. Reset(Source);
  135. While not EOF(Source) do                         {Read data and put in proper}
  136. begin                                            {locations}
  137.   Readln(Source,Line);
  138.   case copy(Line,1,1) of
  139.        'T': begin
  140.                Theacnt:=Theacnt+1;               {Incr theater count}
  141.                with Theater[Theacnt] do          {Insert Theater information}
  142.                   begin
  143.                      Name:=copy(Line,9,15);
  144.                      Val(copy(Line,25,2),x,j);
  145.                      Val(copy(Line,28,2),y,j);
  146.                      Val(copy(Line,31,2),max,j);
  147.                   end;
  148.             end;
  149.        'M': PicName:=copy(Line,9,15)+'.map';
  150.        'X': begin
  151.                Xcnt:=Xcnt+1;
  152.                If Xcnt<21 then
  153.                with Axis_Navy[Xcnt] do            {Install Axis ships}
  154.                   begin
  155.                      Id:=copy(Line,9,10);
  156.                      Model:=copy(Line,31,1);
  157.                      Val(copy(Line,34,2),Theater,j);
  158.                      Status:=0;
  159.                      Val(copy(Line,25,2),Attack,j);
  160.                      Val(copy(Line,28,2),Defense,j);
  161.                      Damage:=0;
  162.                      Fleet:=0;
  163.                      Work1:=0;
  164.                      Work2:=0;
  165.                   end;
  166.             end;
  167.        'A': begin
  168.              Acnt:=Acnt+1;
  169.              If Acnt<48 then
  170.              with Available[Acnt] do              {Install Allied ships}
  171.                  begin
  172.                    Id:=copy(Line,9,10);
  173.                    Model:=copy(Line,31,1);
  174.                    Val(copy(Line,34,2),Theater,j);
  175.                    Val(copy(Line,25,2),Attack,j);
  176.                    Val(copy(Line,28,2),Defense,j);
  177.                 end;
  178.              end;
  179.        'F': Val(copy(Line,9,3),Init_Factor,j);    {Install Initative factor}
  180.        'P': Val(copy(Line,9,3),Points,j);         {Install points allowed}
  181.        'S': Val(copy(Line,9,3),ShipsAllow,j);     {Install ships allowed}
  182.        'V': Val(copy(Line,25,3),Victory_Points_to_win,j);
  183.                                                   {Install points to win}
  184.        'N':                                       {Install navy names}
  185.             case copy(Line,5,1) of
  186.               'X': Axis_Name:=copy(Line,9,10);
  187.               'A': Allied_Name:=copy(Line,9,10);
  188.             end;
  189.  
  190.   end;
  191. end;
  192. ClrScr;
  193. Border(1,1,80,22,1,7,0);                          {Draw border}
  194. Gotoxy(30,3);                                     {Display Combatants}
  195. NormVideo;
  196. Write(' ',Allied_Name,' vs ',Axis_Name,' ');
  197. Gotoxy(22,6);
  198. FastWrite('THEATER',7,0,1);
  199. Gotoxy(42,6);
  200. FastWrite('SHIPS ALLOWED',7,0,1);
  201. For i:= 1 to theacnt  do
  202.   begin
  203.      With Theater[i] do
  204.         begin
  205.            Gotoxy(22,7+i);
  206.            FastWrite(Name,7,0,1);
  207.            Gotoxy(48,7+i);
  208.            LowVideo;
  209.            Write(max);
  210.         end;
  211.   end;
  212. Gotoxy(28,20);
  213. Fastwrite('PRESS ANY KEY TO CONTINUE',7,0,1);
  214. uncursor;
  215. read(kbd,c);
  216. window(2,4,78,20);
  217. Clrscr;
  218. window(1,1,80,25);
  219. Gotoxy(28,5);
  220. FastWrite(ConCat('Ships available to ',Axis_Name),7,0,1);
  221. Gotoxy(10,6);                                     {Display Axis ships}
  222. FastWrite('Attack, Defense, * [Limited Theater Availability] are shown.',7,0,1);
  223. j:=6;k:=7;
  224. For i:= 1 to xcnt do
  225.    Begin
  226.       k:=k+1;
  227.       if k=13 then
  228.          begin
  229.            k:=8;
  230.            j:=j+18;
  231.          end;
  232.       Gotoxy(j,k);
  233.       with Axis_Navy[i] do
  234.          begin
  235.            Write(Attack,Defense);
  236.            if Theater>0 then
  237.              FastWrite('*',7,0,1);
  238.            Gotoxy(j+3,k);
  239.            FastWrite(Id,7,0,1);
  240.          end;
  241.    end;
  242. Gotoxy(28,21);
  243. Fastwrite('Press Return to continue ',7,0,1);
  244. Uncursor;
  245. Read(kbd,c);
  246. Gotoxy(10,23);
  247. Fastwrite('Use cursor keys to make selection. ENTER selects or removes.',
  248.         7,0,1);
  249. Gotoxy(13,24);
  250. FastWrite('END completes selection process. Q or q terminates game.',7,0,1);
  251. Gotoxy(47,5);
  252. Fastwrite(ConCat(Allied_Name,'      '),7,0,1);
  253. Window(4,6,78,21);
  254. Clrscr;
  255. For i:=1 to acnt do                              {Clear select marks}
  256.   with Available[i] do
  257.     Select:='n';
  258. j:=2;k:=2;
  259. For i:= 1 to acnt do                              {Display avail. Allied ships}
  260.    Begin
  261.       k:=k+1;
  262.       if k>12 then
  263.          begin
  264.            k:=3;
  265.            j:=j+18;
  266.          end;
  267.       Gotoxy(j,k);
  268.       with Available[i] do
  269.          begin
  270.             Write(' ',Defense,' ');
  271.             FastWrite(Id,7,0,1);
  272.          end;
  273.    end;
  274.                                                  {Display current stats}
  275. Ship_Stats(1);
  276. j:=1;k:=3;
  277. Ships:=0;
  278. Gotoxy(4,16);
  279. FastWrite('Ship selections remaining -             Points remaining -',7,0,1);
  280. Repeat                                           {Move cursor and select ships}
  281.   Gotoxy(33,16);                                 {until END pressed}
  282.   Write(ShipsAllow-Ships,' ');
  283.   Gotoxy(63,16);
  284.   Write(Points,' ');
  285.   Gotoxy(j,k);
  286.   Fastwrite(chr(26),15,0,3);
  287.   uncursor;
  288.   l:=cursor;
  289.   Gotoxy(j,k);
  290.   Fastwrite(' ',7,0,3);
  291.   case l of                                       {adjust cursor location}
  292.      1 : j:=j-18;
  293.      2 : j:=j+18;
  294.      3 : k:=k-1;
  295.      4 : k:=k+1;
  296.   end;                                           {adjust cursor to wrap if}
  297.   if j<0 then j:=55;                             {invalid request}
  298.   if k<3 then k:=12;
  299.   if j>72 then j:=1;
  300.   if k>12 then k:=3;
  301.   v:=(((j-1) div 18)*10)+k-2;
  302.   if v>acnt then
  303.     begin
  304.       m:=(acnt mod 10)+2;
  305.       n:=0;
  306.       if k>m then n:=-1;
  307.       if l=2 then j:=1;
  308.       if l=4 then k:=3;
  309.       if l=3 then k:=m;
  310.       if l=1 then j:=(((acnt div 10)+n)*18)+1;
  311.       v:=(((j-1) div 18)*10)+k-2;
  312.     end;
  313.   Ship_Stats(v);
  314.   if l=13 then
  315.     begin
  316.       with Available[v] do
  317.         begin
  318.           if Select = 's' then                {Remove ship if selected}
  319.             begin
  320.               Points:=Points+Defense;
  321.               Select:= 'n';
  322.               Gotoxy(j+1,k);
  323.               Write(' ',defense,' ');
  324.               FastWrite(Id,7,0,1);
  325.               Ships:=Ships-1;
  326.             end
  327.           else                                {Add ship if not selected}
  328.             begin
  329.               Points:=Points-Defense;
  330.               Ships:=Ships+1;
  331.               If (Points>-1) and (Ships<=ShipsAllow) then
  332.                 begin
  333.                   Select:= 's';
  334.                   Gotoxy(j+1,k);
  335.                   Write(' ',defense,' ');
  336.                   FastWrite(Id,0,7,1);
  337.                 end
  338.               else                            {Ignore request if not enough}
  339.                 begin                         {points or ships}
  340.                   Points:=Points+Defense;
  341.                   Ships:=Ships-1;
  342.                 end;
  343.             end;
  344.         end;
  345.      end;
  346. until (l=5) or (quitsw=1);
  347. if quitsw<>1 then
  348.   begin
  349.     j:=0;k:=1;
  350.     repeat                                    {Move selected ships to allied}
  351.       repeat                                  {navy}
  352.          j:=j+1;                              {Find selected ship}
  353.       until available[j].select='s';
  354.       with Allied_Navy[k] do                  {Move selected data to navy}
  355.         begin
  356.           ID:=Available[j].ID;
  357.           Model:=Available[j].model;
  358.           Theater:=Available[j].theater;
  359.           Attack:=Available[j].attack;
  360.           Defense:=Available[j].defense;
  361.           Fleet:=0;
  362.           Status:=0;
  363.           Damage:=0;
  364.           Work1:=0;
  365.           Work2:=0;
  366.           k:=k+1;
  367.         end;
  368.     until k>Ships;
  369.     Window(1,23,80,24);                          {Print allied navy selected}
  370.     ClrScr;
  371.     Window(2,6,79,21);
  372.     ClrScr;
  373.     Window(1,1,80,25);
  374.     Gotoxy(33,6);                                 {Display Allied navy}
  375.     FastWrite('Ships Selected',7,0,1);
  376.     j:=0;k:=8;
  377.     For i:= 1 to Ships do
  378.        Begin
  379.           Gotoxy(7+j*18,k);
  380.           with Allied_Navy[i] do
  381.              FastWrite(Id,7,0,1);
  382.           j:=j+1;
  383.           if j=4 then
  384.             begin
  385.               j:=0;
  386.               k:=k+1;
  387.             end;
  388.        end;
  389.     Gotoxy(28,21);
  390.     Fastwrite('PRESS ANY KEY TO CONTINUE',7,0,1);
  391.     Uncursor;
  392.     Read(kbd,c);
  393.     gotoxy(1,1);
  394.     Assign(Source,'fleet.chn');
  395.     Chain(Source);
  396.   end;
  397. Window(1,1,80,25);
  398. ClrScr;
  399. End.
  400.